package com.fr.report.script.function;

import com.fr.report.script.Function;
import com.fr.report.script.Function.Type;
import com.fr.report.script.NormalFunction;
import com.fr.report.script.Primitive;
import java.util.Random;

public class RANDBETWEEN extends NormalFunction
{
  public Object run(Object[] paramArrayOfObject)
  {
    if (paramArrayOfObject.length < 2)
      return Primitive.ERROR_NAME;
    Object localObject1 = paramArrayOfObject[0];
    Object localObject2 = paramArrayOfObject[1];
    if ((localObject1 instanceof Number) && (localObject2 instanceof Number))
    {
      int i = Math.max(((Number)localObject2).intValue(), ((Number)localObject1).intValue());
      int j = Math.min(((Number)localObject2).intValue(), ((Number)localObject1).intValue());
      return new Integer(new Random().nextInt(i - j) + j);
    }
    return Primitive.ERROR_NAME;
  }

  public Function.Type getType()
  {
    return Function.MATH;
  }

  public String getCN()
  {
    return "RANDBETWEEN(value1,value2):返回value1和value2之间的一个随机整数。\n示例：\nRANDBETWEEN(12.333, 13.233)只会返回13。\nRANDBETWEEN(11.2, 13.3)有可能返回12或者13。";
  }

  public String getEN()
  {
    return "";
  }
}